package com.ruoyi.seedlingSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.seedlingSys.domain.Zaipei;
import com.ruoyi.seedlingSys.service.IZaipeiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 栽培管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/seedlingSys/zaipei")
public class ZaipeiController extends BaseController
{
    @Autowired
    private IZaipeiService zaipeiService;

    /**
     * 查询栽培管理列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:zaipei:list')")
    @GetMapping("/list")
    public TableDataInfo list(Zaipei zaipei)
    {
        startPage();
        List<Zaipei> list = zaipeiService.selectZaipeiList(zaipei);
        return getDataTable(list);
    }

    /**
     * 导出栽培管理列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:zaipei:export')")
    @Log(title = "栽培管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Zaipei zaipei)
    {
        List<Zaipei> list = zaipeiService.selectZaipeiList(zaipei);
        ExcelUtil<Zaipei> util = new ExcelUtil<Zaipei>(Zaipei.class);
        util.exportExcel(response, list, "栽培管理数据");
    }

    /**
     * 获取栽培管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:zaipei:query')")
    @GetMapping(value = "/{zaiPeiID}")
    public AjaxResult getInfo(@PathVariable("zaiPeiID") Long zaiPeiID)
    {
        return success(zaipeiService.selectZaipeiByZaiPeiID(zaiPeiID));
    }

    /**
     * 新增栽培管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:zaipei:add')")
    @Log(title = "栽培管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Zaipei zaipei)
    {
        return toAjax(zaipeiService.insertZaipei(zaipei));
    }

    /**
     * 修改栽培管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:zaipei:edit')")
    @Log(title = "栽培管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Zaipei zaipei)
    {
        return toAjax(zaipeiService.updateZaipei(zaipei));
    }

    /**
     * 删除栽培管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:zaipei:remove')")
    @Log(title = "栽培管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zaiPeiIDs}")
    public AjaxResult remove(@PathVariable Long[] zaiPeiIDs)
    {
        return toAjax(zaipeiService.deleteZaipeiByZaiPeiIDs(zaiPeiIDs));
    }
}
